# -*- coding: utf-8 -*-

"""
A Simple HTTP Server For Test
"""

import BaseHTTPServer
import SocketServer

DEFAULT_PORT = 54321


class ThreadingHttpServer(BaseHTTPServer.HTTPServer, SocketServer.ThreadingMixIn):
    pass


class RequestHandler(BaseHTTPRequestHandler):
    def exception(self):
        self.send_response(400)
        self.end_headers()
        self.wfile.write(textwrap.dedent('''
            <html>
            <head><title>400 Bad Request</title></head>
            <body><h1>400 Bad Request</h1></body>
            </html>
        '''))

    def do_GET(self):
        pass

    def do_POST(self):
        pass


def serve(ip='', port=DEFAULT_PORT):
    httpd = ThreadingHttpServer(('',8000), MyRequestHandler)
    print 'HTTP server serving at port  %s...' % port
    httpd.serve_forever()


if __name__ == '__main__':
    serve()
